package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FArray;

public class INDEXOFARRAY extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length != 2)
      return Primitive.ERROR_VALUE;
    Object localObject1 = paramArrayOfObject[1];
    Object localObject2 = paramArrayOfObject[0];
    if ((!(localObject1 instanceof Integer)) || (!(localObject2 instanceof FArray)))
      return Primitive.ERROR_VALUE;
    int i = Integer.parseInt(localObject1.toString());
    FArray localFArray = (FArray)localObject2;
    if ((i < 1) || (i > localFArray.length()))
      return Primitive.NULL;
    return localFArray.elementAt(i - 1);
  }

  public Function.Type getType()
  {
    return Function.ARRAY;
  }

  public String getCN()
  {
    return "INDEXOFARRAY(array, index):返回数组array的第index个元素。\n示例：\nINDEXOFARRAY([\"第一个\", \"第二个\", \"第三个\"], 2)返回\"第二个\"。";
  }

  public String getEN()
  {
    return "";
  }
}